package com.dbh.company.buildbook.gif;

import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * @author dongbanghui
 * @create 2024/1/12
 */
public class GifConvert {

    public static void main(String[] args) {

        String inputPath = "D:\\data\\work\\file\\楼书\\楼书1.0\\gif图\\result\\1.gif";
        String outputPath = "D:\\data\\work\\file\\楼书\\楼书1.0\\gif图\\result\\output.mp4";

        try {
            Process process = Runtime.getRuntime().exec("ffmpeg -i " + inputPath + " -vf scale=980:-1 -pix_fmt yuv420p " + outputPath);
            // 等待ffmpeg命令执行完成
            BufferedReader reader = new BufferedReader(new InputStreamReader(process.getErrorStream()));
            String line;
            while ((line = reader.readLine()) != null) {
                System.out.println(line);
            }

            process.waitFor();
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
